<div class="jumbotron">
	<div class="container text-center">
		<h1 class="brand display-3">统计数据</h1>
	</div>
</div>

<div class="container">
	<div class="row">
		<div class="col-md">
			<p>*注意：由于我们是首家支持统计数据 API 的 Go 模块代理，所以我们预留了一段时间的功能探索期，在此期间内下述所有相关的 API 都算作处在 Beta 阶段。虽然我们可以保证在功能探索期内尽可能地不对现有任何 API 做修改，但在正式发布前任何事情都会有可能发生，届时如有不兼容性改动发生还望大家海涵。新 API 随时都有可能会被添加进来，当然如果你有更好的建议欢迎随时<a href="https://github.com/goproxy/goproxy.cn/issues/new/choose" target="_blank">联系我们</a>。</p>
		</div>
	</div>

	<hr>

	<div id="statsAPI" class="accordion">
		<div class="card">
			<div id="statSummaryAPI" class="card-header">
				<h2 class="mb-0">
					<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#statSummaryAPICollapse" aria-expanded="false" aria-controls="statSummaryAPICollapse">API：获取服务摘要</button>
				</h2>
			</div>

			<div id="statSummaryAPICollapse" class="collapse" aria-labelledby="statSummaryAPI" data-parent="#statsAPI">
				<div class="card-body">
					<p>获取服务的摘要信息，如服务中所有模块版本的总尺寸和总数等。</p>
					<pre><code class="language-http">GET /stats/summary</code></pre>
					<p>示例请求 URL：<a href="https://goproxy.cn/stats/summary" target="_blank">goproxy.cn/stats/summary</a></p>
					<p>示例响应主体：</p>
					<pre><code class="language-json">{
	"cacher_size": 2663405247231,
	"module_version_count": 1035421,
	"module_host_count": 1120,
	"top_10_module_hosts": [
		{"module_host": "github.com", "module_version_count": 921606},
		{"module_host": "k8s.io", "module_version_count": 24982},
		{"module_host": "gitlab.com", "module_version_count": 13172},
		{"module_host": "gopkg.in", "module_version_count": 10479},
		{"module_host": "golang.org", "module_version_count": 8000},
		{"module_host": "gitee.com", "module_version_count": 4650},
		{"module_host": "bitbucket.org", "module_version_count": 4177},
		{"module_host": "sigs.k8s.io", "module_version_count": 3280},
		{"module_host": "google.golang.org", "module_version_count": 2703},
		{"module_host": "istio.io", "module_version_count": 2487}
	]
}</code></pre>
				</div>
			</div>
		</div>

		<div class="card">
			<div id="statTrendAPI" class="card-header">
				<h2 class="mb-0">
					<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#statTrendAPICollapse" aria-expanded="false" aria-controls="statTrendAPICollapse">API：获取模块趋势</button>
				</h2>
			</div>

			<div id="statTrendAPICollapse" class="collapse" aria-labelledby="statTrendAPI" data-parent="#statsAPI">
				<div class="card-body">
					<p>获取服务中的模块趋势，如最近一段时间内最活跃的最多前 1000 个模块。</p>
					<pre><code class="language-http">GET /stats/trends/&lt;trend&gt;</code></pre>
					<p>路径参数 <code>&lt;trend&gt;</code> 是<span class="text-danger">必填的</span>，它拥有三个可选值：<code>latest</code>（最新趋势）、<code>last-7-days</code>（最近 7 天的趋势）和 <code>last-30-days</code>（最近 30 天的趋势）。</p>
					<p>示例请求 URL：<a href="https://goproxy.cn/stats/trends/latest" target="_blank">goproxy.cn/stats/trends/latest</a></p>
					<p>示例响应主体：</p>
					<pre><code class="language-json">[
	{"module_path": "golang.org/x/sys", "download_count": 1822180},
	{"module_path": "golang.org/x/net", "download_count": 1713080},
	{"module_path": "golang.org/x/tools", "download_count": 1503522},
	{"module_path": "golang.org/x/crypto", "download_count": 1032270},
	{"module_path": "gopkg.in/yaml.v2", "download_count": 578120}
]</code></pre>
				</div>
			</div>
		</div>

		<div class="card">
			<div id="statModuleVersionAPI" class="card-header">
				<h2 class="mb-0">
					<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#statModuleVersionAPICollapse" aria-expanded="false" aria-controls="statModuleVersionAPICollapse">API：获取模块（版本）统计</button>
				</h2>
			</div>

			<div id="statModuleVersionAPICollapse" class="collapse" aria-labelledby="statModuleVersionAPI" data-parent="#statsAPI">
				<div class="card-body">
					<p>获取服务中指定模块（版本）的统计，如指定模块（版本）的总下载次数和其在最近 30 天内的单日下载次数。</p>
					<pre><code class="language-http">GET /stats/&lt;module-path&gt;[@&lt;module-version&gt;]</code></pre>
					<p>路径参数 <code>&lt;module-path&gt;</code> 是<span class="text-danger">必填的</span>，如：<code>golang.org/x/text</code>。</p>
					<p>路径参数 <code>&lt;module-version&gt;</code> 是<span class="text-danger">可选的</span>，并且需要注意它只能伴随着前导符号 <code>@</code> 一起出现，如：<code>@v0.3.2</code>。</p>
					<p>示例请求 URL：<a href="https://goproxy.cn/stats/golang.org/x/text" target="_blank">goproxy.cn/stats/golang.org/x/text</a></p>
					<p>示例响应主体：</p>
					<pre><code class="language-json">{
	"download_count": 476705,
	"last_30_days": [
		{"date": "2020-03-25T00:00:00Z", "download_count": 15940},
		{"date": "2020-03-24T00:00:00Z", "download_count": 16884},
		{"date": "2020-03-23T00:00:00Z", "download_count": 15842},
		{"date": "2020-03-22T00:00:00Z", "download_count": 11232},
		{"date": "2020-03-21T00:00:00Z", "download_count": 11894},
		{"date": "2020-03-20T00:00:00Z", "download_count": 14968},
		{"date": "2020-03-19T00:00:00Z", "download_count": 11017},
		{"date": "2020-03-18T00:00:00Z", "download_count": 5209},
		{"date": "2020-03-17T00:00:00Z", "download_count": 5759},
		{"date": "2020-03-16T00:00:00Z", "download_count": 4166},
		{"date": "2020-03-15T00:00:00Z", "download_count": 2145},
		{"date": "2020-03-14T00:00:00Z", "download_count": 2218},
		{"date": "2020-03-13T00:00:00Z", "download_count": 4609},
		{"date": "2020-03-12T00:00:00Z", "download_count": 5503},
		{"date": "2020-03-11T00:00:00Z", "download_count": 5412},
		{"date": "2020-03-10T00:00:00Z", "download_count": 6453},
		{"date": "2020-03-09T00:00:00Z", "download_count": 4798},
		{"date": "2020-03-08T00:00:00Z", "download_count": 2323},
		{"date": "2020-03-07T00:00:00Z", "download_count": 2332},
		{"date": "2020-03-06T00:00:00Z", "download_count": 4806},
		{"date": "2020-03-05T00:00:00Z", "download_count": 6339},
		{"date": "2020-03-04T00:00:00Z", "download_count": 5858},
		{"date": "2020-03-03T00:00:00Z", "download_count": 5579},
		{"date": "2020-03-02T00:00:00Z", "download_count": 8862},
		{"date": "2020-03-01T00:00:00Z", "download_count": 2119},
		{"date": "2020-02-29T00:00:00Z", "download_count": 2053},
		{"date": "2020-02-28T00:00:00Z", "download_count": 4735},
		{"date": "2020-02-27T00:00:00Z", "download_count": 6578},
		{"date": "2020-02-26T00:00:00Z", "download_count": 4954},
		{"date": "2020-02-25T00:00:00Z", "download_count": 5318}
	],
	"top_10_module_versions": [
		{"module_version": "v0.3.2", "download_count": 232795},
		{"module_version": "v0.3.0", "download_count": 146009},
		{"module_version": "v0.3.1-0.20180807135948-17ff2d5776d2", "download_count": 67096},
		{"module_version": "v0.3.1-0.20181227161524-e6919f6577db", "download_count": 11494},
		{"module_version": "v0.0.0-20160726164857-2910a502d2bf", "download_count": 11223},
		{"module_version": "v0.0.0-20170915032832-14c0d48ead0c", "download_count": 3991},
		{"module_version": "v0.3.1-0.20171227012246-e19ae1496984", "download_count": 1128},
		{"module_version": "v0.0.0-20170915090833-1cbadb444a80", "download_count": 937},
		{"module_version": "v0.3.1-0.20181030141323-6f44c5a2ea40", "download_count": 480},
		{"module_version": "v0.3.1", "download_count": 353}
	]
}</code></pre>
					<p>示例请求 URL：<a href="https://goproxy.cn/stats/golang.org/x/text@v0.3.2" target="_blank">goproxy.cn/stats/golang.org/x/text@v0.3.2</a></p>
					<p>示例响应主体：</p>
					<pre><code class="language-json">{
	"download_count": 232795,
	"last_30_days": [
		{"date": "2020-03-25T00:00:00Z", "download_count": 12852},
		{"date": "2020-03-24T00:00:00Z", "download_count": 12708},
		{"date": "2020-03-23T00:00:00Z", "download_count": 12602},
		{"date": "2020-03-22T00:00:00Z", "download_count": 10371},
		{"date": "2020-03-21T00:00:00Z", "download_count": 10673},
		{"date": "2020-03-20T00:00:00Z", "download_count": 11882},
		{"date": "2020-03-19T00:00:00Z", "download_count": 8379},
		{"date": "2020-03-18T00:00:00Z", "download_count": 2244},
		{"date": "2020-03-17T00:00:00Z", "download_count": 2407},
		{"date": "2020-03-16T00:00:00Z", "download_count": 1696},
		{"date": "2020-03-15T00:00:00Z", "download_count": 981},
		{"date": "2020-03-14T00:00:00Z", "download_count": 897},
		{"date": "2020-03-13T00:00:00Z", "download_count": 1898},
		{"date": "2020-03-12T00:00:00Z", "download_count": 2498},
		{"date": "2020-03-11T00:00:00Z", "download_count": 2374},
		{"date": "2020-03-10T00:00:00Z", "download_count": 2491},
		{"date": "2020-03-09T00:00:00Z", "download_count": 1854},
		{"date": "2020-03-08T00:00:00Z", "download_count": 800},
		{"date": "2020-03-07T00:00:00Z", "download_count": 981},
		{"date": "2020-03-06T00:00:00Z", "download_count": 2085},
		{"date": "2020-03-05T00:00:00Z", "download_count": 2642},
		{"date": "2020-03-04T00:00:00Z", "download_count": 2212},
		{"date": "2020-03-03T00:00:00Z", "download_count": 2515},
		{"date": "2020-03-02T00:00:00Z", "download_count": 2832},
		{"date": "2020-03-01T00:00:00Z", "download_count": 785},
		{"date": "2020-02-29T00:00:00Z", "download_count": 871},
		{"date": "2020-02-28T00:00:00Z", "download_count": 2019},
		{"date": "2020-02-27T00:00:00Z", "download_count": 2480},
		{"date": "2020-02-26T00:00:00Z", "download_count": 2163},
		{"date": "2020-02-25T00:00:00Z", "download_count": 2344}
	]
}</code></pre>
				</div>
			</div>
		</div>

		<div class="card">
			<div id="statModuleDownloadCountBadgeAPI" class="card-header">
				<h2 class="mb-0">
					<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#statModuleDownloadCountBadgeAPICollapse" aria-expanded="false" aria-controls="statModuleDownloadCountBadgeAPICollapse">API：获取模块总下载次数徽章</button>
				</h2>
			</div>

			<div id="statModuleDownloadCountBadgeAPICollapse" class="collapse" aria-labelledby="statModuleDownloadCountBadgeAPI" data-parent="#statsAPI">
				<div class="card-body">
					<p>获取服务中指定模块的总下载次数徽章。</p>
					<pre><code class="language-http">GET /stats/&lt;module-path&gt;/badges/download-count.svg</code></pre>
					<p>路径参数 <code>&lt;module-path&gt;</code> 是<span class="text-danger">必填的</span>，如：<code>golang.org/x/text</code>。</p>
					<p>示例请求 URL：<a href="https://goproxy.cn/stats/golang.org/x/text/badges/download-count.svg" target="_blank">goproxy.cn/stats/golang.org/x/text/badges/download-count.svg</a></p>
					<p>示例响应主体：</p>
					<p><img src="https://goproxy.cn/stats/golang.org/x/text/badges/download-count.svg"></p>
					<p>可以通过如下 Markdown 语法将指定模块的总下载次数徽章放入项目的 <code>README.md</code> 中：</p>
					<pre><code class="language-md">[![goproxy.cn](https://goproxy.cn/stats/&lt;module-path&gt;/badges/download-count.svg)](https://goproxy.cn)</code></pre>
				</div>
			</div>
		</div>
	</div>
</div>
